<template>
  <div class="app-container">
    <div class="queryform">
      <el-form ref="form" :model="form" :rules="rules" label-width="95px">
        <el-form-item label="主账号:" prop="params1">
          <el-input v-model="form.params1" placeholder="请输入"></el-input>
        </el-form-item>
        <!-- <el-form-item label="关联区域:" prop="correlateRegion"> </el-form-item> -->
        <el-form-item label="终端IP:" prop="params2">
          <el-input v-model="form.params2" placeholder="请输入"></el-input>
        </el-form-item>
        <!-- <el-form-item label="所属机房:" prop="computer"> </el-form-item> -->
        <el-form-item label="认证时间起:" prop="params3">
          <el-date-picker
            v-model="form.params3"
            value-format="yyyy-MM-dd HH:mm:ss"
            :clearable="false"
            type="datetime"
            placeholder="选择起始日期时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="认证时间止:" prop="params4">
          <el-date-picker
            v-model="form.params4"
            value-format="yyyy-MM-dd HH:mm:ss"
            :clearable="false"
            type="datetime"
            placeholder="选择截止日期时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="refresh">查询</el-button>
          <el-button @click="resetForm">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
    <div class="mod-result-table">
      <HTable
        ref="table"
        :tableData="tableData"
        :columnConfigs="columnConfigs"
        @selection-change="handleSelectionChange"
        :selectable="false"
        orderable
        v-loading="loading"
        :pages="pagination"
        @page-change="handlePageChange"
        @size-change="handleSizeChange"
      >
        <template slot-scope="{row:{name,row,col}}">
          <template v-if="name == 'action'"> </template>
          <template v-else-if="name == 'time'">
            {{ $getTimeStr(row.authenticationStartTime) }}
          </template>
          <template v-else-if="name == 'authenticationResult'">
            <el-tag
              v-if="$getTagType(row.authenticationResult, col.tagTypeObj)"
              :type="$getTagType(row.authenticationResult, col.tagTypeObj)"
              >{{
                $getTagType(row.authenticationResult, col.labelObj)
              }}</el-tag
            >
          </template>
        </template>
      </HTable>
    </div>
  </div>
</template>

<script>
import table from "@/mixins/commontable";
import { columnConfigs } from "./columnConfigs.js";
import { getList } from "@/api/yybl/auth";
export default {
  components: {},
  name:'auth',
  mixins: [table], //表格的混入，主要包括表格上通用的方法和数据，比如查询，重置，分页这些功能
  props: {},
  data() {
    let checkTransparency = (rex, value, callback) => {
      const rule = /^0.\d+$/;
      if (rule.test(value) || value == 0 || value == 1) {
        callback();
      } else {
        callback(new Error("透明度范围为0-1"));
      }
    };
    let checkNumber = (rex, value, callback) => {
      const rule = /^\d*$/;
      if (rule.test(value)) {
        callback();
      } else {
        callback(new Error("请输入数字"));
      }
    };
    return {
      columnConfigs,
      form: {
        params1: "",
        params2: "",
        params3: "",
        params4:""
      },
      rules: {},
    };
  },
  watch: {},
  computed: {},
  methods: {
    handleSelectionChange() {},
    getparams() {
      let obj = [
        {
          name: "params1",
          prop: "userCode",
        },
        {
          name: "params2",
          prop: "terminalIp",
        },
        {
          name: "params3",
          prop: "authenticationStartTimeStr",
        },
        {
          name: "params4",
          prop: "authenticationEndTimeStr",
        },
        // {
        //   name: "params3",
        //   prop: "terminalIp",
        // },
      ];
      let params = {};
      obj.forEach((i) => {
        if (params[i.prop] == undefined) {
          const value = this.form[i.name];
          params[i.prop] = value;
        }
      });
      return params;
    },
    refresh() {
      let params = this.getparams();
      this.getlists(getList, params);
    },
    resetForm() {
      this.$refs["form"].resetFields();
      this.refresh();
    },
  },
  created() {
    this.refresh();
  },
  mounted() {},
};
</script>
<style lang="scss" scoped>
::v-deep .el-form-item__content {
  .el-date-editor.el-input {
    width: 100%;
  }
}
::v-deep .el-button {
  .el-icon-edit + span {
    margin-left: 0px;
  }
  .el-icon-delete + span {
    margin-left: 0px;
  }
}
::v-deep .el-dialog {
  .el-dialog__header {
    border-bottom: 1px solid #e8e8e8;
  }
  .el-dialog__footer {
    border-top: 1px solid #e8e8e8;
  }
}
.queryform {
  ::v-deep .el-form {
    display: flex;
    flex-wrap: wrap;

    .el-form-item {
      max-width: 33.3%;
      flex-grow: 1;
      flex-shrink: 1;
      flex-basis: 33.3%;
    }

    // .el-form-item:nth-child(7) {
    //   max-width: 100%;
    //   flex-basis: 100%;
    //   display: flex;
    //   justify-content: end;
    // }
  }
}
</style>
